/**
 * =============================================================================
 * ************   Tab   ************
 * =============================================================================
 *
 * 在手机上选项卡始终平分或可滚动，在平板以上的设备上默认左对齐，可以选择居中对齐，或全宽等分
 */

/* 选项卡，默认的选项卡为全宽 */
.mdui-tab {
  position: relative;
  display: flex;
  min-height: 48px;
  max-height: 72px;
  margin: 0 auto;
  padding: 0;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;

  a {
    display: flex;
    // 手机上始终等分选项卡
    flex: 1;

    // 使图标和文本垂直排列
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    min-width: 72px;
    min-height: 48px;
    max-height: 72px;
    padding: 12px;
    overflow: hidden;
    color: inherit;
    font-size: 14px;
    text-align: center;
    text-transform: uppercase;
    text-decoration: none;
    text-overflow: ellipsis;
    outline: none;
    cursor: pointer;
    opacity: 0.7;
    user-select: none;

    .mdui-icon {
      opacity: 0.7;
    }

    // 平板或以上设备
    @media (min-width: @screen-sm-min) {

      // 平板/pc上选项卡左对齐
      flex: none;
      min-width: 99px;
      max-width: 264px;

      // 手机上 padding 12px，平板/pc上 padding 24px
      padding: 12px 24px;
    }

    @media (min-width: @screen-md-min) {
      min-width: 112px;
    }

    @media (min-width: @screen-lg-min) {
      min-width: 136px;
    }

    @media (min-width: @screen-xl-min) {
      min-width: 160px;
    }

    label {
      display: block;
      width: 100%;
      cursor: pointer;
    }

    .mdui-icon+label {
      margin-top: 8px;
    }

    &[disabled] {
      cursor: default;
      opacity: 0.38;

      label {
        cursor: default;
      }
    }

    &::before {
      position: absolute;
      right: 0;
      bottom: 0;
      left: 0;
      height: 2px;
      background-color: @color-default-500;
      opacity: 0;
      transition: all 0.35s;
      content: '';
    }
  }

  // 激活状态的选项
  .mdui-tab-active {
    color: @color-default-500;
    opacity: 1;

    .mdui-icon {
      opacity: 1;
    }

    &::before {
      opacity: 1;
    }
  }
}

/* 选项卡居中 */
.mdui-tab-centered {
  @media (min-width: @screen-sm-min) {
    &::before {
      flex-grow: 1;
      content: ' ';
    }

    &::after {
      flex-grow: 1;
      content: ' ';
    }

    a {
      flex: none;
    }
  }
}

/* 选项卡始终全宽等分 */
.mdui-tab-full-width {
  a {
    flex: 1;
    max-width: none;
  }
}


/* 可横向滚动的选项卡 */
.mdui-tab-scrollable {
  a {
    flex: none;
  }
}

/**
 * =============================================================================
 * ************   Tab 主色   ************
 * =============================================================================
 */

& {
  .loop-primary-theme(@counter-color) when (@counter-color > 0) {
    .loop-primary-theme((@counter-color - 1));
    @colorName: extract(@globalPrimaryColors, @counter-color);
    @color: 'color-@{colorName}-500';

    .mdui-theme-primary-@{colorName} when not (@colorName =null) {
      .mdui-tab .mdui-tab-active {
        color: @@color;

        &::before {
          background-color: @@color;
        }
      }
    }

  }

  .loop-primary-theme(length(@globalPrimaryColors));
}

/* 带背景色的选项卡 */
.mdui-tab[class*="mdui-color-"]:not(.mdui-color-white) {
  .mdui-tab-active {
    color: inherit;

    &::before {
      background-color: @color-white-500;
    }
  }

  // 带背景色的选项卡中使用浅色滚动条
  & {
    .mdui-scrollbar-beautify(dark);
  }
}
